﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Historico.aspx.cs" Inherits="Stock_Historico" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
    <script>
    $(function () {
        $("#search").click(function () {
            $("#spinner").show();
            $.ajax({
                type: 'POST',
                url: 'http://localhost:1661/Web/Webservices/ProductsByProviderBranchWS.asmx/getProducts',
                data: {
                    branchId: $("#MainContent_ddlBranches").val(),
                    providerId: $("#MainContent_ddlProviders").val()
                },
                dataType: 'xml',
                success: function (xml) {
                    $("#result").empty();
                    var data;
                    $(xml).find('string').each(function () {
                        data = eval("(" + $(this).text() + ')');
                    });
                    var length = data.length;
                    if (length > 0) {
                        $("#result").append('<table style="color:#333333;width:223px;border-collapse:collapse;margin-right: 3px"><thead><tr style="color:White;background-color:#507CD1;font-weight:bold;"><td align="center">Id. del producto</td><td align="center">Descripción</td></tr></thead><tbody></tbody></table>');
                        $("#result").find("table").find("tbody").empty();
                        for (var i = 0; i < length; i++) {
                            var style = i % 2 == 0 ? "background-color:#EFF3FB;" : "background-color:white;";
                            $("#result").find("table").find("tbody").append("<tr style='" + style + "'><td align='center'>" + data[i].ProductId + "</td><td align='center'>" + data[i].ProductDesctiption + "</td></tr>");
                        }
                    } else {
                        $("#result").append("<p>No hay resultados.</p>");
                    }
                    $("#spinner").hide();
                }
            });
        });
    });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <h2>
        Histórico de productos
    </h2>
    <div style="height: 25px; width: 100%; padding-top: 10px">
        <div style="float: left">
            Sucursal:&nbsp;<asp:DropDownList ID="ddlBranches" runat="server" DataTextField="BranchName"
                DataValueField="BranchId"></asp:DropDownList>
            Sucursal:&nbsp;<asp:DropDownList ID="ddlProviders" runat="server" DataTextField="ProviderName"
                DataValueField="ProviderId"></asp:DropDownList>
            <div style="display: inline; padding-top: 3px">
                <img src="../Images/icon_ok.png" border="0" id="search" alt="Buscar" /></div>
        </div>
        <div id="spinner" style="float: right; display: none">
            <img src="../Images/spinner.gif" border="0" alt="Loading" /></div>
    </div>
    <div id="result" style="height: auto; padding-top: 10px">
        
    </div>
    <asp:hyperlink ID="Hyperlink1" runat="server" NavigateUrl = "~/Stock/Stock.aspx">Stock</asp:hyperlink>
</asp:Content>

